package com.huahua.api.controller;

import com.huahua.api.entity.base.R;
import com.huahua.api.entity.param.YmlFromPropertiesParam;
import com.huahua.api.entity.param.YmlToPropertiesParam;
import com.huahua.api.util.YamlUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LoveHuaHua
 * @date 2023年08月18日 20:46
 * @description believe in yourself
 */
@RestController
@RequestMapping("/yml")
public class YmlConvertController {


    /**
     * yml->properties
     *
     * @param param 参数
     * @return {@link Object}
     */
    @PostMapping("/toProperties")
    public Object ymlToProperties(@RequestBody YmlToPropertiesParam param){
        String properties = YamlUtil.yamlToProperties(param.getContent());
        return R.success(properties);
    }



    /**
     * properties->yml
     *
     * @param param 参数
     * @return {@link Object}
     */
    @PostMapping("/fromProperties")
    public Object fromProperties(@RequestBody YmlFromPropertiesParam param){
        String yml = YamlUtil.propertiesToYaml(param.getContent());
        return R.success(yml);
    }

}
